import { GSprite } from "../../../../com/mui/controls/GSprite";
import { GScrollPane } from "../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { TreasureOverViewNewRender } from "./TreasureOverViewNewRender";
type int = number;
//class TreasureOverViewNewSp
    
    export  class TreasureOverViewNewSp extends GSprite
    {
        constructor(arg1: int, arg2: int)
        {
            super();
            this._width = arg1;
            this._height = arg2;
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._sp = new Object /* flash.display.Sprite */();
            this._scrollPane = new GScrollPane();
            this._scrollPane.x = 0;
            this._scrollPane.y = 0;
            this._scrollPane.width = this._width;
            this._scrollPane.height = this._height;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            this._scrollPane.source = this._sp;
            this._scrollPane.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onPaneMouseDownHandler);
            return;
        }

        /* internal  */onPaneMouseDownHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            arg1.stopImmediatePropagation();
            return;
        }

        public update(arg1: Object, ... rest): void
        {
            var loc2=0;
            var loc4=null;
            var loc1=arg1 as Array<any>;
            var loc3=loc1.length;
            while (this._sp.numChildren > 0) 
            {
                if (!(loc4 = this._sp.removeChildAt(0) as TreasureOverViewNewRender)) 
                {
                    continue;
                }
                loc4.dispose();
                loc4 = null;
            }
            var loc5=0;
            while (loc5 < loc3) 
            {
                (loc4 = new TreasureOverViewNewRender()).setData(loc1[loc5], this._width - 20);
                loc4.y = loc2;
                this._sp.addChild(loc4);
                loc2 = loc2 + loc4.height;
                ++loc5;
            }
            this._scrollPane.update();
            this._scrollPane.drawNow();
            addChild(this._scrollPane);
            return;
        }

        public maxScrollPosition(): void
        {
            this._scrollPane.verticalScrollPosition = this._scrollPane.maxVerticalScrollPosition;
            return;
        }

        /* internal */ /* var */_scrollPane: GScrollPane;

        /* internal */ /* var */_sp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;
    }
